﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twitterizer;

namespace CommonUtils
{
    public class TwitterAPI
    {
        public static void CreateStatus(String message, String consumerKey, String consumerSecret)
        {
            try
            {
                OAuthTokens tokens = new OAuthTokens();
                tokens.AccessToken = CommonUtilsSettings.Default.TwitterApiToken;
                tokens.AccessTokenSecret = CommonUtilsSettings.Default.TwitterApiTokenSecret;
                tokens.ConsumerKey = "dejanlovren";//CommonUtilsSettings.Default.TwitterApiKey;
                tokens.ConsumerSecret = "brodydalle"; //CommonUtilsSettings.Default.TwitterApiSecret;

                TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, message);
                if (tweetResponse.Result == RequestResult.Success)
                {
                    // Tweet posted successfully!
                }
                else
                {
                    // lol penis
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame();
                LogWriter.AddLog(e, LogStatus.Error, CommonUtilsSettings.Default.ApplicationName, sf.GetMethod().Name);
                throw new Exception(sf.GetMethod().Name + " unexpected error", e);
            }
        }
    }
}
